package org.example.strategypatterndemo.Factory;

import org.example.strategypatterndemo.module1.service.PromotionStrategy;
import org.example.strategypatterndemo.module1.service.impl.DiscountStrategy;
import org.example.strategypatterndemo.module1.service.impl.FullReduceStrategy;
import org.example.strategypatterndemo.module1.service.impl.GiftStrategy;

/**
 * PromotionStrategyFactory
 * @author dingchen
 * @version 2025/05/29 17:17
**/
// 促销策略工厂类
class PromotionStrategyFactory {
    public static PromotionStrategy getPromotionStrategy(String strategyType) {
        if (strategyType == null) {
            return null;
        }
        if (strategyType.equalsIgnoreCase("DISCOUNT")) {
            return new DiscountStrategy();
        } else if (strategyType.equalsIgnoreCase("FULL_REDUCE")) {
            return new FullReduceStrategy();
        } else if (strategyType.equalsIgnoreCase("GIFT")) {
            return new GiftStrategy();
        }
        return null;
    }
}
